﻿#include "ThreeDCloudMapSelectDataDialog.h"
#include "BaseWidget/IdaWidgetHelper.h"
#include "BaseModule/IBaseSignal.h"

namespace pst
{
    ThreeDCloudMapSelectDataDialog::ThreeDCloudMapSelectDataDialog(QWidget* parent)
        : IdaDialogFrame(parent)
    {
        ui.setupUi(this);
        setWindowTitle(QStringLiteral("三维云图"));
        IdaWidgetHelperInstance->setMainButtonStyle(ui.pushButton_accept);
        connect(ui.pushButton_accept, &QPushButton::clicked, this, &ThreeDCloudMapSelectDataDialog::slot_buttonBox_accepted);
        connect(ui.pushButton_reject, &QPushButton::clicked, this, &ThreeDCloudMapSelectDataDialog::slot_buttonBox_rejected);
    }

    ThreeDCloudMapSelectDataDialog::~ThreeDCloudMapSelectDataDialog()
    {
    }

    void ThreeDCloudMapSelectDataDialog::setValueNameList(const QList<QString>& valueNameList)
    {
        m_valueNameList = valueNameList;
        ui.comboBox_chooseValue->clear();
        for (const auto& i : m_valueNameList)
        {
            ui.comboBox_chooseValue->addItem(i);
        }
    }

    QList<QString> ThreeDCloudMapSelectDataDialog::getValueNameList()
    {
        return m_valueNameList;
    }

    void ThreeDCloudMapSelectDataDialog::setInfomationGraph3DBasical(InfomationGraph3DBasical* info)
    {
        m_info = info;
    }

    InfomationGraph3DBasical* ThreeDCloudMapSelectDataDialog::getInfomationGraph3DBasical()
    {
        return m_info;
    }

    void ThreeDCloudMapSelectDataDialog::slot_buttonBox_accepted()
    {
        auto index = ui.comboBox_chooseValue->currentIndex();
        m_info->m_valueGroupNameIndex = index;
        m_info->m_valueComponentIndex = 0;//默认第0分量

        //QStringList _pyCodes{};
        //_pyCodes += QString("threedcloudmap = PostProcessing.ThreeDCloudMap()");
        //_pyCodes += QString("threedcloudmap.setVariableIndex(%1)").arg(m_info->m_valueIndex);
        //_pyCodes += QString("threedcloudmap.setReaderIndex(%1)").arg(m_info->readerIndex);
        //_pyCodes += QString("threedcloudmap.setGraphType(%1)").arg((int)(m_info->m_graphType));
        //_pyCodes += QString("threedcloudmap.setFilePath('%1')").arg(m_info->m_filePath);
        //_pyCodes += QString("threedcloudmap.setName('%1')").arg(m_info->m_name.toUtf8().data());
        //_pyCodes += QString("threedcloudmap.setResultDataIndex(%1)").arg(m_info->resultDataIndex);
        //_pyCodes += QString("threedcloudmap.create()");
        //emit IBaseSignalInstance->signal_execPYCode(_pyCodes);

        signal_sentChosenValueNameIndex(m_info, m_isOpenNewWindow);
        this->close();
    }

    void ThreeDCloudMapSelectDataDialog::slot_buttonBox_rejected()
    {
        this->close();
    }
}
